package com.summatech.gwt.mvp.client.presenter;

import java.util.Arrays;
import java.util.List;

import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.mvp4g.client.annotation.Presenter;
import com.summatech.gwt.mvp.client.MultiPresentersEventBus;
import com.summatech.gwt.mvp.client.presenter.SenderPresenter.ISenderView;
import com.summatech.gwt.mvp.client.view.SenderView;

@Presenter(view = SenderView.class, multiple=true)
public class SenderPresenter extends
		AbstractGroupPresenter<ISenderView, MultiPresentersEventBus> {
	public interface ISenderView {
		void showGroup(String group);
		HasChangeHandlers getSelectableComponent();
		String getSelectedValue();
		void displayValues(List<String> asList);
	}
	
	public void bind(){
		view.showGroup(getGroup());
		view.getSelectableComponent().addChangeHandler(new ChangeHandler() {
			public void onChange(ChangeEvent event) {
				eventBus.setSelectedItem(getGroup(),view.getSelectedValue());				
			}
		});
		view.displayValues(Arrays.asList("Texas","Arkansas","Alabama","Delaware","Florida","Georgia","Pennsylvania","Ohio"));
	}
}
